package com.artisan.domain.service;

import com.artisan.domain.dto.AdPositionDto;
import com.artisan.domain.dto.AdTypeDto;
import com.artisan.domain.entity.MAdPosition;
import com.artisan.domain.entity.MAdType;
import com.artisan.domain.repositoryInterface.IAdPositionRepository;
import com.artisan.domain.repositoryInterface.IAdTypeRepository;
import com.artisan.domain.serviceInterface.IAdPositionService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 广告位置业务类
 */
@Service
public class AdPositionService implements IAdPositionService {
    private final IAdPositionRepository adPositionRepository;

    public AdPositionService(IAdPositionRepository adPositionRepository) {
        this.adPositionRepository = adPositionRepository;
    }
    @Override
    public List<AdPositionDto> findList(int status) {
        List<MAdPosition> models = this.adPositionRepository.findList(status);
        List<AdPositionDto> dtos = new ArrayList<>();
        models.forEach(model -> {
            AdPositionDto dto = new AdPositionDto();
            dto.setId(model.getId());
            dto.setName(model.getName());
            dto.setAddDate(model.getAddDate());
            dto.setStatus(model.getStatus());
            dtos.add(dto);

        });
        return dtos;
    }
}
